//
//  DMAdjustAttributionInfo.m
//  DualMediationSDK
//
//  Created by YeJary on 2025/1/5.
//

#import "DMAdjustAttributionInfo.h"
#import <AdjustSdk/AdjustSdk.h>

@implementation DMAdjustAttributionInfo

+ (instancetype)attributionInfoWithADJAttribution:(ADJAttribution *)attribution {
    if (!attribution) {
        return nil;
    }
    
    DMAdjustAttributionInfo *info = [[DMAdjustAttributionInfo alloc] initWithADJAttribution:attribution];
    return info;
}

- (instancetype)initWithADJAttribution:(ADJAttribution *)attribution {
    self = [super init];
    if (self && attribution) {
        self.campaign = attribution.campaign;
        self.creative = attribution.creative;
        self.network = attribution.network;
        self.adgroup = attribution.adgroup;
        self.isOrganic = [attribution.network isEqualToString:@"Organic"];
    }
    return self;
}

- (NSDictionary *)toDictionary {
    return @{
        @"campaign": self.campaign ?: @"",
        @"creative": self.creative ?: @"",
        @"network": self.network ?: @"",
        @"adgroup": self.adgroup ?: @"",
        @"isOrganic": @(self.isOrganic)
    };
}

- (NSString *)description {
    return [NSString stringWithFormat:@"<DMAdjustAttributionInfo: campaign=%@, creative=%@, network=%@, adgroup=%@, isOrganic=%@>",
            self.campaign ?: @"nil",
            self.creative ?: @"nil",
            self.network ?: @"nil",
            self.adgroup ?: @"nil",
            self.isOrganic ? @"YES" : @"NO"];
}

@end
